//
//  UpdateRootViewController.swift
//  d11
//
//  Created by rhonin on 2018/12/3.
//  Copyright © 2018年 Tech_001. All rights reserved.
//

import UIKit

class UpdateRootViewController: UIViewController,UIGestureRecognizerDelegate {
    init() {
        let name = String(describing: type(of: self))
        super.init(nibName: name, bundle: nil)
    }
  
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        // 左滑返回
        self.navigationController?.interactivePopGestureRecognizer?.delegate = self
        self.navigationController?.interactivePopGestureRecognizer?.isEnabled = true
        // 去掉导航栏下面的一条线
        self.navigationController?.navigationBar.shadowImage = UIImage()
    }
    
    // 导航栏左边按钮
    func leftButtonActionWithImg(_ image: String) {
        let naviLeftButton = UIButton.init(type: UIButton.ButtonType.custom)
        naviLeftButton.frame = CGRect.init(x: 0, y: 0, width: 22, height: 22);
        naviLeftButton.setBackgroundImage(UIImage.init(named: image), for: UIControl.State.normal)
        naviLeftButton.setBackgroundImage(UIImage.init(named: image), for: UIControl.State.highlighted)
        naviLeftButton.addTarget(self, action: #selector(doLeftNaviAction), for: UIControl.Event.touchUpInside)
        self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(customView: naviLeftButton)
    }
    
    // 导航栏左边按钮点击
    @objc func doLeftNaviAction() {
        self.navigationController?.popViewController(animated: true)
    }


}
